//
//  EkaButton.swift
//  QCFM2
//
//  Created by iMac on 15/12/21.
//  Copyright © 2015年 kuai. All rights reserved.
//

import UIKit

class EkaButton: UIButton {
    var isPlay:Bool = false
    
    let imgPlay:UIImage = UIImage(named: "bofang")!
    let imgPause:UIImage = UIImage(named: "anxia")!
    
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        
        self.addTarget(self, action: "onClick", forControlEvents: UIControlEvents.TouchUpInside)
    }
    
    func onClick() {
        isPlay = !isPlay
        if isPlay{
            self.setImage(imgPause, forState: UIControlState.Normal)
        }else {
            self.setImage(imgPlay, forState: UIControlState.Normal)
        }
    }
    
    func onPlay() {
        isPlay = true
        self.setImage(imgPause, forState: UIControlState.Normal)
    }
}
